import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueDevTools(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
  //配置网络代理
  server: {
    proxy: {
      '/server': {
        target: 'http://localhost:9999',//代理服务器地址（直接发到网关端口）
        changeOrigin: true,//是否更改请求头中的Origin字段
        rewrite: (path)=> path.replace(/^\/server/,'')//重写路径，去掉/server
      }
    }
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@use "@/styles/variables" as *;`
      }
    }
  }
}) 
